//
// Created by 卫志龙 on 2023/7/27.
//
#define Status int
#define OK 0
#define ERROR 1

#include <stdio.h>
#include <malloc.h>

#define ElementType int

typedef struct DuLNode{
    ElementType data;
    struct DuLNode *prior;
    struct DuLNode *next;
}DuLNode , *DuLNodeList;

Status InitDuLNodeList(DuLNodeList &L) {
    L = *(DuLNodeList*) malloc(sizeof (DuLNodeList));
    return OK;
}

Status Insert_tail(DuLNodeList &L, ElementType e) {
    if (!L) return ERROR;
    DuLNode *p = L;
    while (p->next != NULL) p = p->next;
    DuLNode *newNode = (DuLNode*) malloc(sizeof (DuLNode));
    newNode->data = e; newNode->next = NULL; p->next = newNode;
    newNode->prior = p;
    return OK;
}

Status Insert_MutilTail(DuLNodeList &L, ElementType es[], int len) {
    if (!L) return ERROR;
    for (int i = 0 ; i < len ; i++) {
        Insert_tail(L, es[i]);
    }
    return OK;
}

Status printList(DuLNodeList &L) {
    DuLNode *p = L->next;
    printf("[");
    while (p != NULL) {
        printf("%d,", p->data);
        p = p->next;
    }
    printf("]\n");
    return OK;
}

int main() {
    ElementType es[] = {1,2,3,4,5};
    DuLNodeList L;
    InitDuLNodeList(L);
    Insert_MutilTail(L, es, 5);
    printList(L);
    return 0;
}